/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.transas.zorlog.ui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JPanel;

/**
 * Panel with alpha background and disabled mouse events.
 * @author amalikov
 */
class AlphaPane extends JPanel {
	
	public AlphaPane(float alpha) {
		this.alpha = alpha;
		
		// disable mouse input
		addMouseListener(new MouseListener() {

			@Override
			public void mouseClicked(MouseEvent e) {
			}

			@Override
			public void mousePressed(MouseEvent e) {
			}

			@Override
			public void mouseReleased(MouseEvent e) {
			}

			@Override
			public void mouseEntered(MouseEvent e) {
			}

			@Override
			public void mouseExited(MouseEvent e) {
			}
		});
	}
	
	public AlphaPane() {
		this(0.5f);
	}
	
	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		
		final Rectangle rect = this.getBounds();

		g.setColor(new Color(0, 0, 0, (int)(255 * alpha)));
		g.fillRect(0, 0, rect.width, rect.height);
	}
	
	public void setAlpha(float alpha) {
		this.alpha = alpha;
		repaint();
	}

	private float alpha = 0.5f;
}
